package net.butfly.bus.client.policy;

import net.butfly.bus.config.Config;
import net.butfly.bus.policy.Router;
import net.butfly.bus.policy.RouterBase;

public class SingleRouter extends RouterBase implements Router {
	public SingleRouter(Config config) {
		super(config);
	}

	@Override
	public String route(String tx) {
		String[] nodes = this.config.matchNodeId(tx);
		if (null == nodes)
			return null;
		switch (nodes.length) {
		case 0:
			return null;
		case 1:
			return nodes[0];
		default:
			return null;
		}
	}
}
